
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Service详解 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="动画详解.html" />
    
    
    <link rel="prev" href="BroadcastReceiver.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../常用算法/算法术语.html">
            
                <a href="../常用算法/算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../常用算法/排序算法.html">
            
                <a href="../常用算法/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../常用算法/查找算法.html">
            
                <a href="../常用算法/查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../常用算法/大数相加.html">
            
                <a href="../常用算法/大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../常用算法/集合的所有子集.html">
            
                <a href="../常用算法/集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../常用算法/扫描线种子填充算法.html">
            
                <a href="../常用算法/扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../常用算法/其他算法.html">
            
                <a href="../常用算法/其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../java基础/java常用代码.html">
            
                <a href="../java基础/java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../java基础/JVM详解.html">
            
                <a href="../java基础/JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../java基础/类加载机制.html">
            
                <a href="../java基础/类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../java基础/内存模型.html">
            
                <a href="../java基础/内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../java基础/GC机制.html">
            
                <a href="../java基础/GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../java基础/对象内存布局.html">
            
                <a href="../java基础/对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../java基础/继承多态.html">
            
                <a href="../java基础/继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../java基础/相等判断.html">
            
                <a href="../java基础/相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../java基础/Java容器类.html">
            
                <a href="../java基础/Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../java基础/Java枚举.html">
            
                <a href="../java基础/Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../java基础/自定义异常.html">
            
                <a href="../java基础/自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../java基础/深度拷贝.html">
            
                <a href="../java基础/深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../java基础/泛型详解.html">
            
                <a href="../java基础/泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../java基础/线程详解.html">
            
                <a href="../java基础/线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../java基础/java注解.html">
            
                <a href="../java基础/java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../java基础/数据解析.html">
            
                <a href="../java基础/数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../java基础/java8新特性.html">
            
                <a href="../java基础/java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="基础控件使用.html">
            
                <a href="基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="android零散知识.html">
            
                <a href="android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="android坐标体系.html">
            
                <a href="android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="APP的启动流程.html">
            
                <a href="APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="View加载流程.html">
            
                <a href="View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="事件分发机制.html">
            
                <a href="事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="控件绘制流程.html">
            
                <a href="控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="常用shape.html">
            
                <a href="常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="进程通信.html">
            
                <a href="进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="Binder详解.html">
            
                <a href="Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="Handler详解.html">
            
                <a href="Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="Fragment详解.html">
            
                <a href="Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="Activity详解.html">
            
                <a href="Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="BroadcastReceiver.html">
            
                <a href="BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.12.16" data-path="Service服务.html">
            
                <a href="Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="动画详解.html">
            
                <a href="动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="屏幕刷新机制.html">
            
                <a href="屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="屏幕适配.html">
            
                <a href="屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="图片加载详解.html">
            
                <a href="图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="WebView详解.html">
            
                <a href="WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="沉浸式.html">
            
                <a href="沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="相机模块.html">
            
                <a href="相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="地图模块.html">
            
                <a href="地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="Androidstudio插件开发.html">
            
                <a href="Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="Apk插件化开发.html">
            
                <a href="Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="App组件化开发.html">
            
                <a href="App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="sdk开发.html">
            
                <a href="sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="APP优化.html">
            
                <a href="APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="项目参数配置.html">
            
                <a href="项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="App发布.html">
            
                <a href="App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="Android外挂.html">
            
                <a href="Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="Android字节码插桩.html">
            
                <a href="Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="智能家居.html">
            
                <a href="智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >Service详解</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#service-&#x670D;&#x52A1;"><b>1. </b>Service &#x670D;&#x52A1;</a></li><ul><ul><li><span class="title-icon "></span><a href="#service&#x7684;&#x610F;&#x4E49;"><b>1.1.1. </b>Service&#x7684;&#x610F;&#x4E49;</a></li></ul><li><span class="title-icon "></span><a href="#service-&#x542F;&#x52A8;&#x65B9;&#x5F0F;"><b>1.2. </b>Service &#x542F;&#x52A8;&#x65B9;&#x5F0F;</a></li><ul><li><span class="title-icon "></span><a href="#start&#x6A21;&#x5F0F;"><b>1.2.1. </b>start&#x6A21;&#x5F0F;</a></li><li><span class="title-icon "></span><a href="#bind&#x6A21;&#x5F0F;"><b>1.2.2. </b>bind&#x6A21;&#x5F0F;</a></li></ul><li><span class="title-icon "></span><a href="#bindservice--"><b>1.3. </b>bindService( , ,)</a></li><li><span class="title-icon "></span><a href="#service-&#x751F;&#x547D;&#x5468;&#x671F;"><b>1.4. </b>service &#x751F;&#x547D;&#x5468;&#x671F;</a></li><li><span class="title-icon "></span><a href="#onstartcommand"><b>1.5. </b>onStartCommand()</a></li><li><span class="title-icon "></span><a href="#&#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;"><b>1.6. </b>&#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;</a></li><li><span class="title-icon "></span><a href="#intentservice"><b>1.7. </b>IntentService</a></li><li><span class="title-icon "></span><a href="#service-&#x548C;-activity-&#x901A;&#x4FE1;"><b>1.8. </b>Service &#x548C; Activity &#x901A;&#x4FE1;</a></li></ul></ul></div><a href="#service-&#x670D;&#x52A1;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="service-&#x670D;&#x52A1;"><a name="service-&#x670D;&#x52A1;" class="anchor-navigation-ex-anchor" href="#service-&#x670D;&#x52A1;"><i class="fa fa-link" aria-hidden="true"></i></a>1. Service &#x670D;&#x52A1;</h1>
<p>Service &#x662F;&#x8FD0;&#x884C;&#x5728;&#x4E3B;&#x7EBF;&#x7A0B;&#x4E2D;&#x7684;&#xFF0C; &#x6240;&#x4EE5; Service &#x5904;&#x7406;&#x4E0D;&#x5F53; &#x4E5F;&#x662F;&#x4F1A;&#x5F15;&#x8D77; ANR &#x7684;&#x3002;
&#x5982;&#x679C;&#x6709;&#x8017;&#x65F6;&#x64CD;&#x4F5C;&#x5728;Service&#x91CC;&#xFF0C;&#x5C31;&#x5FC5;&#x987B;&#x7528;&#x5B50;&#x7EBF;&#x7A0B;&#x5904;&#x7406; &#x3002;</p>
<h3 id="service&#x7684;&#x610F;&#x4E49;"><a name="service&#x7684;&#x610F;&#x4E49;" class="anchor-navigation-ex-anchor" href="#service&#x7684;&#x610F;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. Service&#x7684;&#x610F;&#x4E49;</h3>
<pre><code class="lang-text">1&#x3001;&#x4F18;&#x5148;&#x7EA7;&#x9AD8;&#xFF0C;&#x4E0D;&#x5BB9;&#x6613;&#x88AB;&#x7CFB;&#x7EDF;&#x6740;&#x6B7B;&#x3002;&#x7528;&#x6765;&#x5B9E;&#x73B0;&#x9700;&#x8981;&#x7A33;&#x5B9A;&#x3001;&#x957F;&#x65F6;&#x95F4;&#x8FD0;&#x884C;&#x7684;&#x6A21;&#x5757;&#x3002;
(Service&#x7684;&#x4F18;&#x5148;&#x7EA7;&#x9AD8;&#x4E8E;&#x540E;&#x53F0;&#x6302;&#x8D77;&#x7684;Activity&#xFF0C; &#x4E5F;&#x9AD8;&#x4E8E;Activity&#x6240;&#x521B;&#x5EFA;&#x7684;Thread)

2&#x3001;&#x7528;&#x5728;&#x4E00;&#x4E9B;&#x4E0D;&#x9002;&#x5408;activity&#x7684;&#x7684;&#x573A;&#x666F;&#x3002;&#x4F8B;&#x5982;&#x97F3;&#x4E50;&#x64AD;&#x653E;&#x548C;&#x6587;&#x4EF6;&#x4E0B;&#x8F7D;&#x7B49;&#x573A;&#x666F; &#x3002;
</code></pre>
<h2 id="service-&#x542F;&#x52A8;&#x65B9;&#x5F0F;"><a name="service-&#x542F;&#x52A8;&#x65B9;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#service-&#x542F;&#x52A8;&#x65B9;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. Service &#x542F;&#x52A8;&#x65B9;&#x5F0F;</h2>
<p>&#x56E0;&#x4E3A; startService &#x65B9;&#x5F0F;&#x4E0D;&#x80FD;&#x83B7;&#x5F97;service&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x80FD;&#x4E0D;&#x80FD;&#x62FF;&#x5230;AIDL&#x5B9A;&#x4E49;&#x7684;&#x63A5;&#x53E3;&#xFF0C;&#x65E0;&#x6CD5;&#x53CC;&#x5411;&#x901A;&#x4FE1;&#x3002;
&#x6240;&#x4EE5;aidl&#x4E2D;&#x53EA;&#x80FD;&#x7528; bindService &#x65B9;&#x5F0F;&#xFF0C;&#x6839;&#x636E; ServiceConnection &#x83B7;&#x5F97;&#x63A5;&#x53E3;&#x3002;</p>
<h3 id="start&#x6A21;&#x5F0F;"><a name="start&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#start&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.1. start&#x6A21;&#x5F0F;</h3>
<p>&#x4E00;&#x65E6;&#x542F;&#x52A8;&#xFF0C;Service&#x5C06;&#x4E00;&#x76F4;&#x8FD0;&#x884C;&#x5728;&#x540E;&#x53F0;&#xFF0C;&#x5373;&#x4FBF;&#x542F;&#x52A8;Service&#x7684;&#x7EC4;&#x4EF6;&#x5DF2;&#x88AB;destroy&#x3002;</p>
<pre><code class="lang-text">Intent intent = new Intent(this, MyNormalService.class);
startService(intent);//&#x542F;&#x52A8;&#x670D;&#x52A1;

stopService(intent) ;//&#x505C;&#x6B62;&#x670D;&#x52A1;
//&#x6216;&#x5728;&#x670D;&#x52A1;&#x7C7B;&#x4E2D; &#x8C03;&#x7528; stopSelf();
</code></pre>
<h3 id="bind&#x6A21;&#x5F0F;"><a name="bind&#x6A21;&#x5F0F;" class="anchor-navigation-ex-anchor" href="#bind&#x6A21;&#x5F0F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.2. bind&#x6A21;&#x5F0F;</h3>
<p>&#x901A;&#x8FC7;&#x7ED1;&#x5B9A;&#x65B9;&#x5F0F;&#x542F;&#x52A8;&#x7684;Service&#x662F;&#x4E00;&#x4E2A;client-server&#x7ED3;&#x6784;&#x3002;
&#x591A;&#x4E2A;&#x7EC4;&#x4EF6;&#x53EF;&#x4E0E;&#x4E00;&#x4E2A;service&#x7ED1;&#x5B9A;&#xFF0C;service&#x4E0D;&#x518D;&#x4E0E;&#x4EFB;&#x4F55;&#x7EC4;&#x4EF6;&#x7ED1;&#x5B9A;&#x65F6;&#xFF0C;&#x8BE5;service&#x4F1A;&#x88AB;destroy&#x3002;</p>
<pre><code class="lang-text">Intent intent = new Intent(MainActivity.this, MyNormalService.class) ;
this.bindService( intent, serviceConnection , BIND_AUTO_CREATE  ); // &#x7ED1;&#x5B9A;
this.unbindService(serviceConnection); // &#x89E3;&#x7ED1;

// &#x542F;&#x52A8;&#x8FDC;&#x7A0B;service ,&#x6BD4;&#x5982;aidl&#x901A;&#x4FE1;&#x65F6;&#xFF0C;service&#x4E0D;&#x5728;&#x540C;&#x4E00;&#x4E2A;APP&#x3002;
Intent intent=new Intent();
intent.setAction(&quot;com.remoteService.test&quot;); //&#x7528;&#x6765;&#x8BC6;&#x522B;service&#x7684;&#x6807;&#x8BB0;
intent.setPackage(&quot;com.wk.iadlservice&quot;); // &#x670D;&#x52A1;&#x6240;&#x5728;&#x7684;&#x5E94;&#x7528;id
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

ServiceConnection serviceConnection = new ServiceConnection(){
    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        MyNormalService.MyBinder myBinder = (MyNormalService.MyBinder) service ;
        myBinder.func1();//&#x8C03;&#x7528;&#x81EA;&#x5B9A;&#x4E49;Binder&#x4E2D;&#x7684;&#x65B9;&#x6CD5;
    }

    @Override
    public void onServiceDisconnected(ComponentName name)   {   }
} ;

//MyNormalService.java
@Override
public IBinder onBind(Intent intent){
    return new MyBinder();
}

class  MyBinder  extends Binder{
   public void func1(){
    ...
   }
}
</code></pre>
<pre><code class="lang-text">public class MyNormalService extends Service{
    // &#x901A;&#x8FC7;start&#x65B9;&#x5F0F;&#x542F;&#x52A8; &#x65F6;&#x56DE;&#x8C03;&#x7684;&#x65B9;&#x6CD5;
    @Override
    public IBinder onBind(Intent intent){  .... }

    // &#x901A;&#x8FC7;bind&#x65B9;&#x5F0F;&#x542F;&#x52A8; &#x56DE;&#x8C03;&#x7684;&#x65B9;&#x6CD5;
    @Override
    public int onStartCommand(Intent intent, int flags, int startId){ ... }
}
</code></pre>
<h2 id="bindservice--"><a name="bindservice--" class="anchor-navigation-ex-anchor" href="#bindservice--"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. bindService( , ,)</h2>
<p>bindService(  , ,  int flags ) flags &#x542B;&#x4E49;</p>
<pre><code class="lang-text">BIND_AUTO_CREATE    //&#x82E5;&#x7ED1;&#x5B9A;&#x670D;&#x52A1;&#x65F6;&#x670D;&#x52A1;&#x672A;&#x542F;&#x52A8;&#xFF0C;&#x5219;&#x4F1A;&#x81EA;&#x52A8;&#x542F;&#x52A8;&#x670D;&#x52A1;&#x3002;
BIND_DEBUG_UNBIND   // &#x4F7F;&#x7528;&#x6B64;&#x6807;&#x5FD7;&#x7ED1;&#x5B9A;&#x670D;&#x52A1;&#x4E4B;&#x540E;&#x7684;unBindService &#x65B9;&#x6CD5;&#x4F1A;&#x65E0;&#x6548;&#x3002; &#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x4F1A;&#x5F15;&#x8D77;&#x5185;&#x5B58;&#x6CC4;&#x9732;&#xFF0C;&#x5EFA;&#x8BAE;&#x53EA;&#x5728;&#x8C03;&#x8BD5;&#x65F6;&#x4F7F;&#x7528;&#x3002;
BIND_NOT_FOREGROUND // &#x88AB;&#x7ED1;&#x5B9A;&#x7684;&#x670D;&#x52A1;&#x8FDB;&#x7A0B;&#x4F18;&#x5148;&#x7EA7;&#x4E0D;&#x5141;&#x8BB8;&#x88AB;&#x63D0;&#x5230; FOREGROUND &#x7EA7;&#x522B;
BIND_ABOVE_CLIENT   // &#x5982;&#x679C;&#x5F53;&#x7ED1;&#x5B9A;&#x670D;&#x52A1;&#x671F;&#x95F4;&#x9047;&#x5230;OOM&#x9700;&#x8981;&#x6740;&#x6B7B;&#x8FDB;&#x7A0B;&#xFF0C;&#x5BA2;&#x6237;&#x8FDB;&#x7A0B;&#x4F1A;&#x5148;&#x4E8E;&#x670D;&#x52A1;&#x8FDB;&#x7A0B;&#x88AB;&#x6740;&#x6B7B;&#x3002;
BIND_WAIVE_PRIORITY //  &#x88AB;&#x7ED1;&#x5B9A;&#x7684;&#x670D;&#x52A1;&#x8FDB;&#x7A0B;&#x4E0D;&#x4F1A;&#x88AB;OOM&#x5217;&#x5165;&#x730E;&#x6740;&#x5BF9;&#x8C61;&#x4E2D;&#x3002;
</code></pre>
<h2 id="service-&#x751F;&#x547D;&#x5468;&#x671F;"><a name="service-&#x751F;&#x547D;&#x5468;&#x671F;" class="anchor-navigation-ex-anchor" href="#service-&#x751F;&#x547D;&#x5468;&#x671F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. service &#x751F;&#x547D;&#x5468;&#x671F;</h2>
<pre><code class="lang-text">// &#x624B;&#x52A8;&#x8C03;&#x7528;&#x65B9;&#x6CD5; 
startService() 
stopService()     
bindService()     
unbindService() 

// &#x5185;&#x90E8;&#x81EA;&#x52A8;&#x8C03;&#x7528;&#x7684;&#x65B9;&#x6CD5; 
onCreat() 
onStartCommand()    &#x5F00;&#x59CB;&#x670D;&#x52A1;
onDestroy() 
onBind()     
onUnbind()
</code></pre>
<p><img src="../pics/service&#x751F;&#x547D;&#x5468;&#x671F;.png" alt=""></p>
<h2 id="onstartcommand"><a name="onstartcommand" class="anchor-navigation-ex-anchor" href="#onstartcommand"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. onStartCommand()</h2>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C; onStartCommand &#x8FD4;&#x56DE;&#x503C; START_STICKY_COMPATIBILITY &#x6216; START_STICKY &#x3002;</p>
<pre><code class="lang-text">1&#x3001;START_STICKY           //  &#x4F1A;&#x91CD;&#x542F;&#x670D;&#x52A1;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x4F20;&#x9012;null&#x7684;intent&#x3002;
&#x5982;&#x679C;Service&#x6240;&#x5728;&#x7684;&#x8FDB;&#x7A0B;&#xFF0C;&#x5728;&#x6267;&#x884C;&#x4E86;onStartCommand&#x65B9;&#x6CD5;&#x540E;&#xFF0C;&#x88AB;&#x6E05;&#x7406;&#x4E86;&#xFF0C;
&#x90A3;&#x4E48;&#x8FD9;&#x4E2A;Service&#x4F1A;&#x88AB;&#x4FDD;&#x7559;&#x5728;&#x5DF2;&#x5F00;&#x59CB;&#x7684;&#x72B6;&#x6001;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x4FDD;&#x7559;&#x4F20;&#x5165;&#x7684;Intent&#xFF0C;
&#x968F;&#x540E;&#x7CFB;&#x7EDF;&#x4F1A;&#x5C1D;&#x8BD5;&#x91CD;&#x65B0;&#x521B;&#x5EFA;&#x6B64;Service&#xFF0C;&#x7531;&#x4E8E;&#x670D;&#x52A1;&#x72B6;&#x6001;&#x4FDD;&#x7559;&#x5728;&#x5DF2;&#x5F00;&#x59CB;&#x72B6;&#x6001;&#xFF0C;
&#x6240;&#x4EE5;&#x521B;&#x5EFA;&#x670D;&#x52A1;&#x540E;&#x4E00;&#x5B9A;&#x4F1A;&#x8C03;&#x7528;onStartCommand&#x65B9;&#x6CD5;&#x3002;
&#x5982;&#x679C;&#x5728;&#x6B64;&#x671F;&#x95F4;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x542F;&#x52A8;&#x547D;&#x4EE4;&#x88AB;&#x4F20;&#x9012;&#x5230;service&#xFF0C;&#x90A3;&#x4E48;&#x53C2;&#x6570;Intent&#x5C06;&#x4E3A;null&#xFF0C;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x5C0F;&#x5FC3;&#x5904;&#x7406;&#x3002;

2&#x3001;START_NOT_STICKY       // &#x4E0D;&#x4F1A;&#x91CD;&#x542F;&#x670D;&#x52A1;&#x3002;&#x8FD9;&#x662F;&#x6700;&#x5B89;&#x5168;&#x7684;&#x9009;&#x9879;
&#x5982;&#x679C;Service&#x6240;&#x5728;&#x7684;&#x8FDB;&#x7A0B;&#xFF0C;&#x5728;&#x6267;&#x884C;&#x4E86;onStartCommand&#x65B9;&#x6CD5;&#x540E;&#xFF0C;&#x88AB;&#x6E05;&#x7406;&#x4E86;&#xFF0C;&#x5219;&#x7CFB;&#x7EDF;&#x4E0D;&#x4F1A;&#x91CD;&#x65B0;&#x542F;&#x52A8;&#x6B64;Service&#x3002;

3&#x3001;START_REDELIVER_INTENT //  &#x4F1A;&#x91CD;&#x542F;&#x670D;&#x52A1;&#x3002;&#x4F20;&#x5165;&#x6700;&#x540E;&#x4E00;&#x4E2A;intent &#x3002;
&#x5982;&#x679C;&#x7CFB;&#x7EDF;&#x5728; onStartCommand() &#x8FD4;&#x56DE;&#x540E;&#x7EC8;&#x6B62;&#x670D;&#x52A1;&#xFF0C;&#x5219;&#x4F1A;&#x91CD;&#x5EFA;&#x670D;&#x52A1;&#xFF0C;&#x5E76;&#x901A;&#x8FC7; &#x4F20;&#x9012;&#x7ED9;&#x670D;&#x52A1;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A; Intent&#x3002;

4&#x3001;START_STICKY_COMPATIBILITY //   
&#x662F;START_STICKY &#x7684;&#x517C;&#x5BB9;&#x7248;&#x672C;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x4FDD;&#x8BC1;&#x88AB;&#x6E05;&#x7406;&#x540E; onStartCommand&#x65B9;&#x6CD5;&#x4E00;&#x5B9A;&#x4F1A;&#x88AB;&#x91CD;&#x65B0;&#x8C03;&#x7528;&#x3002;
</code></pre>
<h2 id="&#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;"><a name="&#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;" class="anchor-navigation-ex-anchor" href="#&#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x524D;&#x53F0;&#x670D;&#x52A1;&#x3001;&#x540E;&#x53F0;&#x670D;&#x52A1;</h2>
<pre><code class="lang-text">// 1&#x3001;&#x524D;&#x53F0;&#x670D;&#x52A1;
&#x524D;&#x53F0;&#x670D;&#x52A1;&#x5FC5;&#x987B;&#x7ED9;&#x72B6;&#x6001;&#x680F;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x901A;&#x77E5; &#x3002; &#x7CFB;&#x7EDF;&#x5185;&#x5B58;&#x4E0D;&#x8DB3;&#x7684;&#x65F6;&#x5019;&#x4E0D;&#x5141;&#x8BB8;&#x7CFB;&#x7EDF;&#x6740;&#x6B7B;&#x7684;&#x670D;&#x52A1;&#x3002;

// &#x53C2;&#x6570;&#x4E00;&#xFF1A;&#x552F;&#x4E00;&#x7684;&#x901A;&#x77E5;&#x6807;&#x8BC6;&#xFF1B;&#x53C2;&#x6570;&#x4E8C;&#xFF1A;&#x901A;&#x77E5;&#x6D88;&#x606F;&#x3002;
xx.startForeground(12345, notification);// &#x5F00;&#x59CB;&#x524D;&#x53F0;&#x670D;&#x52A1;
xx.stopForeground(true);// &#x505C;&#x6B62;&#x524D;&#x53F0;&#x670D;&#x52A1;--&#x53C2;&#x6570;&#xFF1A;&#x8868;&#x793A;&#x662F;&#x5426;&#x79FB;&#x9664;&#x4E4B;&#x524D;&#x7684;&#x901A;&#x77E5;
</code></pre>
<h2 id="intentservice"><a name="intentservice" class="anchor-navigation-ex-anchor" href="#intentservice"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. IntentService</h2>
<pre><code class="lang-text">1&#x3001;public abstract class IntentService extends Service..
2&#x3001;HandlerThread thread = new HandlerThread(&quot;IntentService[&quot; + mName + &quot;]&quot;)..
3&#x3001;mServiceHandler = new ServiceHandler(mServiceLooper)..

1&#x3001;&#x5185;&#x90E8;&#x5DF2;&#x7ECF;&#x91C7;&#x7528;&#x4E86;&#x72EC;&#x7ACB;&#x7684;&#x5B50;&#x7EBF;&#x7A0B;&#x5904;&#x7406;&#x95EE;&#x9898;&#x3002;&#x65E0;&#x9700;&#x624B;&#x52A8;&#x5F00;&#x542F;&#x5B50;&#x7EBF;&#x7A0B;&#x3002;
2&#x3001;&#x5185;&#x90E8;&#x91C7;&#x7528;&#x961F;&#x5217;&#x5904;&#x7406;&#x95EE;&#x9898;&#x3002; &#x4E0D;&#x7528;&#x8003;&#x8651;&#x591A;&#x7EBF;&#x7A0B;&#x5E76;&#x53D1;&#x95EE;&#x9898;&#x3002;
3&#x3001;&#x4EFB;&#x52A1;&#x7ED3;&#x675F;&#x540E;&#x4F1A;&#x81EA;&#x52A8;&#x505C;&#x6B62;&#x3002;&#x65E0;&#x9700;&#x624B;&#x52A8;&#x8C03;&#x7528;&#x505C;&#x6B62;&#x4EE3;&#x7801;&#x3002; &#x89E3;&#x51B3;Service&#x5185;&#x5B58;&#x6CC4;&#x6F0F;&#x95EE;&#x9898;&#x3002;
</code></pre>
<h2 id="service-&#x548C;-activity-&#x901A;&#x4FE1;"><a name="service-&#x548C;-activity-&#x901A;&#x4FE1;" class="anchor-navigation-ex-anchor" href="#service-&#x548C;-activity-&#x901A;&#x4FE1;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. Service &#x548C; Activity &#x901A;&#x4FE1;</h2>
<pre><code class="lang-text">1&#x3001;bindService &#x542F;&#x52A8;&#x7684;&#x670D;&#x52A1; 
&#x901A;&#x8FC7; ServiceConnection  &#x62FF;&#x5230; service&#x7684;&#x5F15;&#x7528;&#xFF0C;&#x7ED9;&#x5B83;&#x53D1;&#x9001;&#x6570;&#x636E;&#x3002;   activity - &gt; service
&#x901A;&#x8FC7;&#x53D1;&#x9001;&#x5E7F;&#x64AD;&#xFF0C;&#x5E7F;&#x64AD;&#x5728;&#x901A;&#x8FC7;&#x56DE;&#x8C03;&#x63A5;&#x53E3; &#x628A;&#x6D88;&#x606F;&#x4F20;&#x7ED9; activity &#x3002;   service -&gt; activity

2&#x3001;startService &#x542F;&#x52A8;&#x7684;&#x670D;&#x52A1;
eventbus&#x7B49;&#x7B2C;&#x4E09;&#x65B9;&#x5E93; &#x5B9E;&#x73B0;  activity - &gt; service &#x3002; // &#x5982;&#x679C;&#x4E0D;&#x7528;&#x7B2C;&#x4E09;&#x65B9;&#x5E93; &#x600E;&#x4E48;&#x5B9E;&#x73B0;&#xFF1F;
&#x901A;&#x8FC7;&#x5E7F;&#x64AD; &#x53D1;&#x6D88;&#x606F;&#x7ED9;activity &#x3002;  service -&gt; activity
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="BroadcastReceiver.html" class="navigation navigation-prev " aria-label="Previous page: BroadcastReceiver详解">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="动画详解.html" class="navigation navigation-next " aria-label="Next page: 动画详解">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Service详解","level":"1.12.16","depth":2,"next":{"title":"动画详解","level":"1.12.17","depth":2,"path":"chinese/android基础/动画详解.md","ref":"chinese/android基础/动画详解.md","articles":[]},"previous":{"title":"BroadcastReceiver详解","level":"1.12.15","depth":2,"path":"chinese/android基础/BroadcastReceiver.md","ref":"chinese/android基础/BroadcastReceiver.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/android基础/Service服务.md","mtime":"2022-04-04T02:49:02.749Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

